package cn.bearspark.happening.provider.dao.mapper;

import cn.bearspark.happening.provider.dao.po.HappeningImgPO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 动态的图片的数据映射接口
 *
 * @author f
 */
@Mapper
public interface HappeningImgMapper {

    /**
     * 批量添加动态的图片数据
     *
     * @param happeningId 动态的 id
     * @param imgUrlList  图片的 url 集合
     */
    void insertBatch(long happeningId, List<String> imgUrlList);

    /**
     * 获取指定动态的图片路径集合
     *
     * @param happeningIdList 指定动态的 id 集合
     * @return 指定动态的图片路径集合
     */
    List<HappeningImgPO> listByHappeningIdList(List<Long> happeningIdList);

    /**
     * 查询指定动态的图片路径集合
     *
     * @param happeningId 指定动态的 id
     * @return 指定动态的图片路径集合
     */
    @Select("SELECT img_url FROM t_happening_img WHERE happening_id = #{happeningId}")
    List<String> listByHappeningId(long happeningId);

    /**
     * 删除指定动态的所有图片路径
     *
     * @param happeningId 指定动态的 id
     */
    @Delete("DELETE FROM t_happening_img WHERE happening_id = #{happeningId}")
    void deleteByHappeningId(long happeningId);
}
